home *** CD-ROM | disk | FTP | other *** search
- /* Moniker 2.0.1 */
- /* Copyright ©1992 by Michael J. Simms */
-
- /* Include the program header. */
- #include "Moniker 2.0.1.h"
- #include "AppleEvents.h"
-
-
- /* Function prototypes. */
- OSErr gotRequired(AppleEvent *);
- pascal OSErr HandleODOC(AppleEvent *, AppleEvent *, long);
- pascal OSErr HandleQUIT(AppleEvent *, AppleEvent *, long);
- pascal OSErr HandleOAPP(AppleEvent *, AppleEvent *, long);
- pascal OSErr HandlePDOC(AppleEvent *, AppleEvent *, long);
-
- /* External decalaration. */
- extern Boolean gQuitDemand;
-
-
- OSErr
- gotRequired(AppleEvent *theAppleEvent)
- /* Checks for the required number of parameters. */
- {
- OSErr myErr;
- DescType typeCode;
- Size actualSize;
-
- myErr=AEGetAttributePtr(theAppleEvent,keyMissedKeywordAttr,typeWildCard,
- &typeCode,NIL,0,&actualSize);
- if (myErr==errAEDescNotFound) myErr=noErr;
- else if (myErr==noErr) myErr=errAEEventNotHandled;
- return(myErr);
- }
-
-
- pascal OSErr
- HandleODOC(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
- /* Handles the OpenDocument Apple Event. */
- {
- long itemsInList,count;
- Size actualSize;
- OSErr myErr;
- FSSpec myFSS;
- DescType typeCode;
- AEKeyword theKeyword;
- AEDescList docList;
-
- if (!(myErr=AEGetParamDesc(theAppleEvent,keyDirectObject,typeAEList,&docList))) {
-
- if (!(myErr=gotRequired(theAppleEvent))) {
-
- if (!(myErr=AECountItems(&docList,&itemsInList))) {
- /* Make an alias for each one of the documents. */
-
- /* Get the file(s) information. */
- for (count=1;count<=itemsInList;count++) {
- myErr=AEGetNthPtr(&docList,count,typeFSS,&theKeyword,
- &typeCode,(Ptr)&myFSS,sizeof(FSSpec),&actualSize);
- if (!myErr) makeAlias(myFSS);
- else describeError(myErr);
- }
-
- } else describeError(myErr);
-
- } else describeError(myErr);
-
- } else describeError(myErr);
-
- /* Set 'gQuitDemand' to TRUE (we are done). */
- gQuitDemand=TRUE;
-
- return(myErr);
- }
-
-
- pascal OSErr
- HandleQUIT(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
- /* Handles the QuitApplication Apple Event. */
- {
- return(errAEEventNotHandled);
- }
-
-
- pascal OSErr
- HandlePDOC(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
- /* Handles the PrintDocument Apple Event. */
- {
- return(errAEEventNotHandled);
- }
-
-
- pascal OSErr
- HandleOAPP(AppleEvent *theAppleEvent,AppleEvent *reply,long myRefCon)
- /* Handles the OpenApplication Apple Event. */
- {
- /* Show the 'explain' box. */
- showExplainBox();
-
- /* Set 'gQuitDemand' to TRUE (we are done). */
- gQuitDemand=TRUE;
-
- return(noErr);
- }